<%@ page language="java" import="com.ruohi.util.common.CommonApplication,com.ruohi.util.common.CommonForm"
         pageEncoding="UTF-8" %>
<%@ page import="com.ruohi.util.common.CommonString" %>
<%@ page import="com.ruohi.util.common.Env" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.TreeMap" %>
<%
	String tablePrefix = Env.getInstance().getProperty("table_prefix");
	String tableName = "gift_customize_product";
	String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
	String fileds = "id,uuid,no,name,cus_category,category,price_category,min_cus_count,price,view_count,is_show,index_order_no,order_no,is_cus_index_rec,is_rec_index";
	String whereStr = "";
	String orderByStr = " id desc ";
	
	//供应商
	Map supplierMap = (Map)application.getAttribute("giftSupplierMap");
	
	//定制类别
	Map cus_category_map = CommonApplication.getEnumChildren("197", application);
	
	//产品类别
	Map categoryMap = new TreeMap();
	List<Map> categoryList = (List)application.getAttribute("giftCategoryList");
	String n = "";
	String name = "";
	if(categoryList != null){
		for(Map m : categoryList){
			n = (String)m.get("no");
			name = (String)m.get("name");
			name = CommonForm.getHtmlSpaceByString((String)m.get("parent_no"))+name;
			categoryMap.put(n,name);
		}
	}
	
	//价格区间类别
	Map price_category_map = CommonApplication.getEnumChildren("196", application);
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><%=Env.getInstance().getProperty("project_name") %></title>
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
  	<div class="searchForm">
  		<div class="searchCondition">
        	<div class="searchLeft">编号</div>
	  		<div class="searchRight">
	  			<input type="text" style="width: 120px;" name="no" class="jr_text" id="no" />
	  		</div>
	  		<div class="searchLeft">名称</div>
	  		<div class="searchRight">
	  			<input type="text" style="width: 120px;" name="name" class="jr_text" id="name" />
	  		</div>
	  		<div class="searchLeft">定制类别</div>
	  		<div class="searchRight">
	  			<select class="jr_select" id="cus_category" name="cus_category">
                    <option value="">--请选择--</option>
                    <%=CommonForm.createSelect(cus_category_map, "") %>
                </select>
	  		</div>
	  		<div class="searchLeft">商城类别</div>
	  		<div class="searchRight">
	  			<select class="jr_select" id="category" name="category">
                    <option value="">--请选择--</option>
                    <%=CommonForm.createSelect(categoryMap, "") %>
                </select>
	  		</div>
	  		<div class="searchLeft">价格区间</div>
	  		<div class="searchRight">
	  			<select class="jr_select" id="price_category" name="price_category">
                    <option value="">--请选择--</option>
                    <%=CommonForm.createSelect(price_category_map, "") %>
                </select>
	  		</div>
	  		<div class="searchLeft">是否上架</div>
	  		<div class="searchRight">
	  			<select class="jr_select" id="is_show" name="is_show" >
                    <option value="">--请选择--</option>
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
	  		</div>
	  		<div class="searchLeft">首页推荐</div>
	  		<div class="searchRight">
	  			<select class="jr_select" id="is_cus_index_rec" name="is_cus_index_rec" >
                    <option value="">--请选择--</option>
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
	  		</div>
  		</div>
  		<div class="searchBtn">
  			<input type="button" class="btn" onclick="doSearch();" value="查询" />
  			<input type="button" class="btn" onclick="doClearForm();" value="重置" />
  		</div>
  	</div>
	<div style="clear: left;"></div>
	<div class="l-loading" style="display: block" id="pageloading"></div> 
	<div id="maingrid" style="margin: 0; padding: 0"></div>
	<div style="display: none;"></div>
  </body>
</html>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js" prefix="<%=tablePrefix %>" type="text/javascript"></script>
<script type="text/javascript">
	var grid;
	var tableName = "<%=tableName %>";
	var channelUUID = '<%=channelUUID%>';
	var fields = "<%=fileds %>";
	var whereStr = "<%=whereStr %>";
	var orderBy = "<%=orderByStr %>";
	var columnsArr = [];
	var url = "";
	var conditionStr = "";
	var params = [];
	jQuery(function() {
		params.push({'name':'enumNo','value':'106013','fileName':'test'});
		grid = new Dev21sunGrid();
		jQuery("#pageloading").hide();
	});
	//列数组
	columnsArr =  [ 
	{ display : '名称', name : 'name'  , id : 'no', align : 'left' , type : 'string' , width : 240 , render : function(row){
        return "<a target='_blank' href='http://www.52sdskj.com/customize/" + row.no + ".htm'><img class='preview' src='/plugin/ui/ligerUI/ligerUI/skins/icons/preview.png' /></a><a class='link' href='javascript:void(0);' onclick='addAndEdit(" + row.__index + ");'>" + row.name + "</a>";
			}
		} ,
	{ display : '编号', name : 'no'  , align : 'left' , type : 'string' , width : 150 , render : function(row){
			return "<a class='link' href='javascript:void(0);' onclick='addAndEdit("+row.__index+");'>"+row.no+"</a>";
		}
	}  ,
	{ display:"定制类别", name:"cus_category", align:"center", type:"string", width:90, render:function(row){
		return getEnum(row.cus_category);
	} },
	{ display:"商城类别", name:"category", align:"center", type:"string", width:100, render:function(row){
		return getGiftCategory(row.category,"giftCategoryMap");	
	} },
	{ display:"价格区间", name:"price_category", align:"center", type:"string", width:90, render:function(row){
		return getEnum(row.price_category);
	} },
	{ display : '最低起订量', name : 'min_cus_count'  , align : 'center' , type : 'int' , width : 80 } ,
	{ display:"价格", name:"price", align:"center", type:"string", width:100 },
	{ display:"是否上架", align:"center", type:"int", width:70, render:function(row){
		return row.is_show==1 ? "是" : "否";
	} },
	{ display : '点击量', name : 'view_count'  , align : 'center' , type : 'string' , width : 60 },
	{ display:"定制首页推荐", align:"center", width:90, render:function(row){
		return row.is_cus_index_rec==1 ? "是" : "否";
	} },
	{ display:"定制首页排序", align:"center", width:80, type:"string", render:function(row){
		return row.is_cus_index_rec==1 ? row.index_order_no+"" : "";
	} },
	{ display : '首页推荐', name : 'is_rec_index'  , align : 'center' , type : 'string' , width : 80 } 
	];
	
	function addAndEdit(index){
		if(undefined==index){//如果是增加
			toolbarAdd({
				width:800,
				height:630,
				title:"增加",
				params : {
	    			channel_uuid : "<%=channelUUID %>"
	    		}
			});
		}else{//如果是修改
	    	var row = grid.getRow(index);
	    	toolbarAdd({width:800,height:630,title:'编辑'},row.uuid);
		}
    }
	/*列表页条件查询*/
	function doSearch(){
		params = [];
		conditionStr = "";
		var no = jQuery("#no").val();
		if(''!=jQuery.trim(no)){
			conditionStr += " and no like '%"+no+"%' ";
		}
		var name = jQuery("#name").val();
		if(''!=jQuery.trim(name)){
			conditionStr += " and name like '%"+name+"%' ";
		}
		var cus_category = $.trim($("#cus_category").val());
		if(cus_category != ""){
			conditionStr += " and cus_category='" + cus_category + "'";
		}
		var category = $.trim($("#category").val());
		if(category != ""){
			conditionStr += " and category like '" + category + "%'";
		}
		var price_category = $.trim($("#price_category").val());
		if(price_category != ""){
			conditionStr += " and price_category='" + price_category + "'";
		}
		var is_show = $.trim($("#is_show").val());
		if(is_show!=""){
			conditionStr += " and is_show="+is_show;
		}
		var is_cus_index_rec = $.trim($("#is_cus_index_rec").val());
		if(is_cus_index_rec!=""){
			conditionStr += " and is_cus_index_rec="+is_cus_index_rec;
		}
		params.push({'name':'tableName','value':tableName});
		params.push({'name':'enumNo','value':'106013'});
		params.push({'name':'fields','value':fields});
		params.push({'name':'whereStr','value':conditionStr});
		params.push({'name':'orderBy','value':orderBy});
		grid.options.parms=params;
		grid.loadData();
	}
</script>